package com.alt.www.leetCode;

/**
 * Created by wangyang on 2017/12/7.
 */
public class Palindrome {
    public static void main(String[] args) {
        System.out.println(isPalindrome(121));
        System.out.println(isPalindrome(12233451));
        System.out.println(isPalindrome(111222));
        System.out.println(isPalindrome(1112111));
        System.out.println(isPalindrome(332233));
    }

    public static boolean isPalindrome(int x) {
        String s = String.valueOf(x);
        char[] chars = s.toCharArray();
        for(int i=0,j=chars.length-1;i<chars.length;i++,j--){
            if(i>=j){
                return true;
            }
            if(chars[i]!=chars[j]){
                return false;
            }
        }
        return false;
    }
}
